package com.hangzhou.xyj.ui.listener;

import android.content.Context;
import android.view.View;

import com.hangzhou.xyj.manager.IntentManager;
import com.hangzhou.xyj.model.DramaModel;
import com.hangzhou.xyj.model.SingModel;
import com.hangzhou.xyj.model.type.EIntentTagType;
import com.hangzhou.xyj.utils.LogUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by neo.duan on 2016/4/19.
 * 戏曲item的点击监听器
 */
public class DramaItemClickListener implements View.OnClickListener {
    private static final String TAG = "DramaItemClickListener";
    private int mDramaPos;
    private Context mContext;
    private List<SingModel> mDramaList;
    private EIntentTagType mIntentTag;

    public DramaItemClickListener(Context context, List<SingModel> modelList, int dramaPos, EIntentTagType tagType) {
        this.mContext = context;
        this.mDramaList = modelList;
        this.mDramaPos = dramaPos;
        this.mIntentTag = tagType;
    }

    public DramaItemClickListener(Context context, List<SingModel> modelList, int dramaPos) {
        this.mContext = context;
        this.mDramaList = modelList;
        this.mDramaPos = dramaPos;
    }

    @Override
    public void onClick(View v) {
        if (mDramaList == null) {
            LogUtil.e(TAG, "mDramaList is null");
            return;
        }
        List<DramaModel> list = new ArrayList<>();
        for (SingModel model : mDramaList) {
            if (model == null) {
                continue;
            }
            DramaModel dramaModel = new DramaModel();
            dramaModel.setId(model.getId()); //戏曲id
            dramaModel.setName(model.getDramaName());//戏曲名称
            dramaModel.setNativeUrl(model.getNativeUrl()); //原唱
            dramaModel.setAccompanyUrl(model.getAccompanyUrl()); //伴奏
            dramaModel.setLrcUrl(model.getLrcUrl()); //歌词
            list.add(dramaModel);
        }
        IntentManager.getInstance().goDramaPlayActivity(mContext, list, mDramaPos, mIntentTag);
    }
}
